﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wolfy.NetDisk.Core;
using Wolfy.NetDisk.Site.Models;

namespace Wolfy.NetDisk.Site.Controllers
{
    public class ErrorController : Controller
    {
        public ActionResult Index(Exception error)
        {
            Response.StatusCode = 500;
            var m = error.Message;
            if (error.InnerException != null) m += " | " + error.InnerException.Message;
            ViewBag.Message = m;
            if (Request.IsAjaxRequest())
            {
                if (error is NetDiskException)
                    return View("Expectedp");
                return View("Errorp");
            }

            if (error is NetDiskException)
                return View("Expected", new ErrorDisplay { Message = error.Message });
            return View("Error", new ErrorDisplay { Message = error.Message });
        }
        public ActionResult Error()
        {
            return View();
        }
        public ActionResult Expectedp()
        {
            return View();
        }
        public ActionResult Expected()
        {
            return View();
        }
        public ActionResult HttpError404(Exception error)
        {
            Response.StatusCode = 404;
            return View();
        }

        public ActionResult HttpError505(Exception error)
        {
            Response.StatusCode = 505;
            return View();
        }
    }
}